package com.ruoyi.business.service;

import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Task;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

public interface IProcessService {
    /**
     * 根据文件进行部署
     * @param filePath
     * @return
     */
    Deployment deploy(String filePath) throws IOException;

    /**
     * 根据部署ID查询对应的流程定义信息
     * @param deploymentId
     * @return
     */
    ProcessDefinition selectProcessDefinitionByDeploymentId(String deploymentId);

    /**
     * 根据流程部署ID和流程名称获取对应的输入流信息
     * @param deploymentId
     * @param resourceName
     * @return
     */
    InputStream getResourceAsStream(String deploymentId, String resourceName);

    /**
     * 根据流程定义ID获取对应的png图片
     * @param processDefinitionId
     * @return
     */
    InputStream getProcessImage(String processDefinitionId,
                                   List<String> highLightedActivities,
                                   List<String> highLightedFlows);

    /**
     * 启动流程
     * @param definitionKey
     * @param businessKey
     * @param variables
     * @return
     */
    ProcessInstance startProcessInstanceByKey(String definitionKey, String businessKey, Map<String, Object> variables);

    /**
     * 根据流程实例ID查询任务
     * @param instanceId
     * @return
     */
    Task getTaskByInstanceId(String instanceId);

    /**
     * 给任务添加候选人
     * @param taskId
     * @param candidateUser
     */
    void addCandidateUser(String taskId, String candidateUser);

    /**
     * 根据流程实例ID获取流程实例对象
     * @param processInstanceId
     * @return
     */
    ProcessInstance getProcessInstanceById(String processInstanceId);

    /**
     * 根据流程实例获取目前活动节点
     * @param processInstanceId
     * @return
     */
    List<String> getActiveActivityIds(String processInstanceId);

    /**
     * 删除流程实例
     * @param instanceId
     * @param reason
     */
    void deleteProcessInstance(String instanceId, String reason);

    long selectTodoTaskCount(String definitionKey, String candidateUser);
    /**
     * 根据流程定义key和候选人Id查询待办任务
     * @param definitionKey
     * @param candidateUser
     * @return
     */
    List<Task> selectTodoTaskList(String definitionKey, String candidateUser,Integer firstResult,Integer pageSize);

    /**
     * 根据任务Id获取任务信息
     * @param taskId
     * @return
     */
    Task getTaskByTaskId(String taskId);

    /**
     * 添加备注，领取任务,完成任务
     * @param task
     * @param userId
     * @param auditStatusBoolean
     * @param commentStr
     */
    void claimAndComplateTask(Task task, String userId, boolean auditStatusBoolean, String commentStr);

    void setVariable(String taskId, String variableName, long variableValue);
    long selectDoneTaskCount(String definitionKey, String userId);
    List<HistoricTaskInstance> selectDoneTaskList(String definitionKey, String userId,Integer firstResult,Integer pageSize);
    HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId);
    List<HistoricActivityInstance> selectHistoryTaskList(String instanceId);
    String getTaskComment(String taskId);

}
